<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- 
	Bean.....: Questao
	BeanClass: QuestaoController
	Servlet..: 
	Descricao: Lista de questoes
 -->
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jstl/core"
    xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
    xmlns:rich="http://richfaces.ajax4jsf.org/rich"
    xmlns:jopcs="http://net.sf.jOpinionPoll/composition"
    xmlns:jopcc="http://net.sf.jOpinionPoll/tag/component/core">
    <ui:composition template="/pages/publico/template/default.xhtml">
        <ui:define name="titulo">
            <h:outputText value="#{msg['privado.questionario.listagemQuestao.titulo']}" />
        </ui:define>
        <ui:define name="corpo">
            <f:view>
				<a4j:keepAlive beanName="Questionario"/>
                <a4j:keepAlive beanName="Questao"/>
                <jopcs:caixaMensagem />

                <!-- titulo -->
                <jopcc:simpleTitle text="#{msg['privado.questionario.listagemQuestao.titulo']}" styleClass="boxTitulo" lineStyleClass="boxTituloLine" />

                <a4j:form id="formLista">
                    <!-- Filtro -->
                    <rich:simpleTogglePanel opened="false"
                                            switchType="client"
                                            label="#{msg['comum.filtro']}"
                                            id="filtro">
                        <table class="textoNormal">
                            <tr>
                                <!-- max resultados -->
                                <td align="left">
                                    <h:outputLabel for="resultados" value="#{msg['comum.resultados']}" />
                                </td>
                                <td>
                                    <h:selectOneMenu id="resultados" value="#{Questao.maximoRegistros}">
                                        <f:selectItem itemValue="10" itemLabel="10" />
                                        <f:selectItem itemValue="50" itemLabel="50" />
                                        <f:selectItem itemValue="100" itemLabel="100" />
                                        <f:selectItem itemValue="500" itemLabel="500" />
                                        <f:selectItem itemValue="1000" itemLabel="1000" />
                                    </h:selectOneMenu>
                                </td>
                            </tr>
                            <tr>
                                <!-- nome -->
                                <td align="left">
                                    <h:outputLabel for="nome" value="#{msg['privado.questionario.listagemQuestao.nome']}" />
                                </td>
                                <td>
                                    <h:inputText id="nome" styleClass="texto" required="false" value="#{Questao.questaoFiltro.descricao}" />
                                </td>
                            </tr>
                        </table>
    
                        <table width="100%" align="center">
                            <!-- separador -->
                            <tr>
                                <td>
                                    <br />
                                    <rich:separator height="4" width="100%" lineType="double" />
                                </td>
                            </tr>

                            <!-- comandos -->
                            <tr align="right">
                                <td class="caixaTitulo">
                                    <table>
                                        <tr>
                                            <td>
                                                <a4j:commandButton styleClass="button" value="#{msg['comum.filtrar']}" reRender="filtro, scrollerList, listaItens, mensagem" actionListener="#{Questao.filtrarListener}" />
                                            </td>
                                            <td>
                                                <a4j:commandButton styleClass="button" value="#{msg['comum.limpar']}" reRender="filtro, scrollerList, listaItens, mensagem" actionListener="#{Questao.limparFiltroListener}" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </rich:simpleTogglePanel>
					<p/>

                	<!-- Lista -->
                    <rich:dataTable
                       id="listaItens"
                       rows="#{Questao.registrosPagina}"
                       cellpadding="0" cellspacing="0"
                       border="0"
					   width="100%"
                       columnsWidth="66%, 22%, 6%, 6%"
                       value="#{Questao.questoesList}"
                       var="item" 
                       columnClasses="colunaTabelaAlinhadaEsquerda, colunaTabelaAlinhadaDireita, colunaTabelaAlinhadaCentro, colunaTabelaAlinhadaCentro"
                       rowClasses="linhaTabela1, linhaTabela2">
                        <f:facet name="header">
                            <rich:columnGroup>
								<rich:column rowspan="2">
                                    <a4j:commandLink reRender="listaItens, scrollerList"
                                         value="#{msg['privado.questionario.listagemQuestao.descricao']}"
                                         actionListener="#{Questao.orderListByDescricaoListener}" />
								</rich:column>
                                <rich:column rowspan="2">
                                    <a4j:commandLink reRender="listaItens, scrollerList"
                                         value="#{msg['privado.questionario.listagemQuestao.data']}"
                                         actionListener="#{Questao.orderListByDataListener}" />
                                </rich:column>
                                <rich:column colspan="2">
                                    <h:outputText
                                        value="#{msg['comum.acoes']}" />
                                </rich:column>
                                <rich:column breakBefore="true">
                                    <h:outputText value="#{msg['comum.editar']}" />
                                </rich:column>
                                <rich:column>
                                    <h:outputText value="#{msg['comum.apagar']}" />
                                </rich:column>
                            </rich:columnGroup>
                        </f:facet>
                        <rich:column>
                            <h:outputText value="#{item.descricao}"/>
                        </rich:column>
                        <rich:column>
                            <h:outputText value="#{item.data}">
                                <f:convertDateTime type="both" pattern="#{msg['configuracao.formatoDataHora']}" timeZone="#{msg['configuracao.timezone']}"/>
                            </h:outputText>
                        </rich:column>
                        <rich:column>
                            <h:commandLink actionListener="#{Questao.editarListener}" action="#{Questao.editarAction}">
                                <h:graphicImage class="imagemBotaoAcao" alt="Edit" url="/pages/publico/images/editar.gif" />
								<f:param name="questionarioId" value="#{Questionario.questionario.id}" />
                                <f:param name="questaoId" value="#{item.id}" />
                            </h:commandLink>
                        </rich:column>
                        <rich:column>
                            <a4j:commandLink
                                reRender="listaItens, scrollerList"
								actionListener="#{Questao.apagarListener}"
                                onclick="ret = confirm('#{msg['comum.confirmacaoParaApagar']} [#{item.descricao}]'); if (!ret) return false;">
                                <h:graphicImage class="imagemBotaoAcao" alt="Del" url="/pages/publico/images/apagar.gif" />
                            </a4j:commandLink>
                        </rich:column>
                    </rich:dataTable>
					<p/>
					
                    <table class="textoNormal" cellspacing="0" cellpadding="0" width="100%">
                        <tr>
                            <td>
                                <table>
                                    <tr>
                                        <td>
											<rich:datascroller
											   id="scrollerList"
											   for="listaItens"
											   maxPages="15" />
										</td>
									</tr>
								</table>
                            </td>
                            <td align="right">
                                <h:outputText value="#{msg['comum.linhasPorPagina']}"/>
                            </td>
                            <td align="right" width="60px">
								<h:selectOneMenu id="registrosPagina" style="width=50px" value="#{Questao.registrosPagina}">
								    <f:selectItem itemValue="5" itemLabel="5" />
									<f:selectItem itemValue="10" itemLabel="10" />
									<f:selectItem itemValue="15" itemLabel="15" />
									<f:selectItem itemValue="20" itemLabel="20" />
									<f:selectItem itemValue="30" itemLabel="30" />
									<a4j:support event="onchange" reRender="listaItens, scrollerList"/>
                                </h:selectOneMenu>
                            </td>
                        </tr>
                    </table>
					<p/>
					
					<rich:separator height="2" width="100%" lineType="dotted" />
					
					<table class="textoNormal">
                        <tr align="right">
                            <td class="caixaTitulo">
                                <table>
                                    <tr>
                                        <td>
                                            <h:commandButton styleClass="button" style="width:auto;" actionListener="#{Questao.adicionarListener}" action="#{Questao.adicionarAction}" value="#{msg['privado.questionario.listagemQuestao.novaQuestao']}"/>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </a4j:form>
            </f:view>
        </ui:define>
    </ui:composition>
</html>